package com.itzdm.mapper;

import com.itzdm.pojo.Car;
import com.itzdm.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {



    @Select("select * from user where username = #{username} and pwd = #{pwd}")
    User login(User user);

    @Select("select count(*) from user where username = #{username}")
    int isExit(String username);

    @Select("select pwd from user where username = #{username}")
    String getPwd(String username);

    @Insert("insert into user(name, username, pwd,idcard) VALUES (#{name},#{username},#{pwd},#{IdNumber})")
    void addUser(String username,String pwd,String name,String IdNumber);

    @Select("select count(*) from user where idcard = #{idcard}")
    int IdisExit(String idcard);

    @Update("update user set money = #{money} where username = #{username}")
    void charge(double money,String username);

    @Select("select money from user where username = #{username}")
    double getMoney(String username);

    @Select("select id from user where username = #{username}")
    Integer getUserId(String username);

    @Select("select money from user where id = #{userId}")
    Double getRemindMoney(Integer userId);

    @Update("update user set money = #{money} where id = #{userId}")
    void updateRemindMoney(double money, Integer userId);
}
